var xx=new Array(10);
var yy=new Array(10);
var tt=new Array(10);
function HTMLDecode ( input )
{
var converter = document.createElement("DIV");
converter.innerHTML = input;
var output = converter.innerText;
converter = null;
return output;
}
$(document).ready(function(){  
		//弹出登录窗口和隐藏窗口
		jQuery(window.parent.document).find("#login").show("slow");
		jQuery(window.parent.document).find("#rightFrame").animate({ width: 0}, 10 );
  
  var onDockSleep = function(){ 
        var dock = $('.jqDock', this); 

        dock.animate({bottom:-1*(dock.height()),opacity:0},800);

        $(this).one('mousemove', function(){

            dock.stop().animate({opacity:1,bottom:0},600);

            $(this).trigger('docknudge');
            return false;
          });
        //don't let the dock go to sleep...
        return false;
      };

  
  var dockOptions =
    { align: 'bottom' ,
	size: 40,
    labels: true,
	idle : 4000, 
	onSleep: onDockSleep
	};
		$("#menu").jqDock(dockOptions);	
		//********************Mouse Over below*********************
		$("#Toolbar").mouseover(function(){
			$("#Toolbar").animate({"width":"250px"},300) ;
			});	
		$("#fly").mouseover(function(){
			//alert("dddddddd");
			jQuery(window.parent.document).find("#Menu").slideDown("normal");
			});				
		jQuery(window.parent.document).find("#Menu").mouseout(function(){
				 jQuery(window.parent.document).find("#Menu").slideUp("normal");
		 });	
		$("#myFavor").mouseover(function(){
		
			 jQuery(window.parent.document).find("#Menu").slideUp("normal");
			 });	
		$("#clear").mouseover(function(){
			jQuery(window.parent.document).find("#Menu").slideUp("normal");
			});
		//**********************Click Below*************************
		$("#Login").click(function(){
			jQuery(window.parent.document).find("#login").show("slow");					
			});
		$("#pan").click(function(){
			window.parent.document.frames["mainFrame"].pan_Method();
		});
		$("#entire").click(function(){
			window.parent.document.frames["mainFrame"].viewEntire();
		});
		$("#select").click(function(){
			window.parent.document.frames["mainFrame"].showHouseInfo();	
		});
		$("#clear").click(function(){
			window.parent.document.frames["mainFrame"].clearMarks();	
		});
		$("#test").click(function(){
			window.parent.document.frames["mainFrame"].selectMarkEvent();
		});		
		//标注
		$("#mark").click(function(){
			var uid= window.parent.document.frames["login"].session;
			//alert("mark:"+uid);					
			if(uid!=null)
			{
				window.parent.document.frames["mainFrame"].Mark();
			}
			else
			{					
				alert("您还没有登录，请登录");
			}		
			
			});					
		$("#find").click(function(){
			jQuery(window.parent.document).find("#POI").show("slow");
			});	
		


		$("#push").click(function(){
			var uid= window.parent.document.frames["login"].session;
			window.parent.document.frames["rightFrame"].removeItems();
			window.parent.document.frames["rightFrame"].destroyEvent();					
		//alert(uid);				
			if(uid!=null)
			{							
				jQuery(window.parent.frames["rightFrame"].document).find(".titleBox").html("猜您喜欢");	
				//取消所有选中状态
				window.parent.document.frames["mainFrame"].removeSelect3D();
				jQuery(window.parent.document).find("#rightFrame").fadeIn(1000);	
				jQuery(window.parent.document).find("#rightFrame").animate({ width: 240}, 1000 );
				jQuery(window.parent.frames["rightFrame"].document).find("#SPIC").attr("src","images/rightslide.png");	
																	
				jQuery.getJSON(ServletAddress+pushAddress+"UID="+uid,function(jsresult){						
				var len=null;
				if(jsresult.length<=10)
				{
					len=jsresult.length;
				}
				else
				{
					len=10;
				}
				for(var i=0;i<len;i++)
				{
					//str+=jsresult[i].premise;
					//通过FavorID查看收藏的房屋信
					var push=jsresult[i];
					
					//选中状态
					window.parent.document.frames["mainFrame"].addSelect3D(push.HID);
					window.parent.document.frames["rightFrame"].addItem(push.HID,push.premise);							
					window.parent.document.frames["rightFrame"].addSubItem3(push.area,push.housePrice,push.type,push.location,push.arrow,push.floor);							
				
				}	
				}).complete(function(){
					//alert("服务器正在努力工作中。。。。请稍后");
					window.parent.document.frames["rightFrame"].addEvent();
					
				});						
			}
			else
			{
				alert("您还没有登录，请登录");
			}				
		});			
			var len=null;
			var firstIndex=null;
			var lastIndex=null;
			var resultCount=null;
			var arrIndex=0;
		
		$("#myMark").click(function(){
			//window.location.reload(true);
			var uid= window.parent.document.frames["login"].session;	
		
			if(uid!=null)
			{	
				window.parent.document.frames["rightFrame"].removeItems();
				window.parent.document.frames["rightFrame"].destroyEvent();
				jQuery(window.parent.document).find("#rightFrame").fadeIn(1000);
				//标题	
				jQuery(window.parent.frames["rightFrame"].document).find(".titleBox").html("我的标注");		
				
				jQuery(window.parent.document).find("#rightFrame").animate({ width: 240}, 1000 );
				jQuery(window.parent.frames["rightFrame"].document).find("#SPIC").attr("src","images/rightslide.png");	
				//情况原来的查询结
				var KeyWord=jQuery("#Search").attr("value");	
				
				jQuery.getJSON(ServletAddress+getMarkAddress+"UID="+uid,function(jsresult){									
				
				if(jsresult!=null)
				{
					resultCount=jsresult.length;
					if(jsresult.length<=12)
					{
						len=jsresult.length;
					}
					else
					{
						len=12;
					}
					lastIndex=resultCount-1;
					firstIndex=resultCount-len-1;
					for(var i=lastIndex;i>firstIndex;i--)
					{
						
						yy[arrIndex]=jsresult[i].location.lat;
						xx[arrIndex]=jsresult[i].location.lng;	
						var text=HTMLDecode(jsresult[i].title);
						//alert(text);
						//var mid=jsresult[i].MID;
						//alert(mid);
						tt[arrIndex]=text;									
						//addItem2(jsresult[i].MID,jsresult[i].title);	
						window.parent.document.frames["rightFrame"].addItem2(jsresult[i].MID,HTMLDecode(jsresult[i].title));							
						//addSubItem2(text);	
						window.parent.document.frames["rightFrame"].addSubItem2(text);	
						arrIndex++;
					}							
				}
				
				for(var i=0;i<len;i++)
				{
					window.parent.frames["mainFrame"].LocationMark(xx[i],yy[i],0,tt[i]);		
				}					
				
				}).complete(function(){
					window.parent.document.frames["rightFrame"].addEvent();
				});	
			}
			else
			{
				alert("您还没有登录，请登录");
			}
			//window.parent.frames["mainFrame"].bubbleTest();
		});	
		
		//统计分析
		$("#statistic").click(function(){
			var winDialog=window.open(ServletAddress+"tabs2.html","tabs","toolbar=no,top=100,left=100,directories=no,status=no,menubar=no,scrollbars=no,location=no,resizable=yes,width=600,height=400");
			winDialog.focus();
			//flyToHouse(25);
		});	
	
		$("#Register").click(function(){
		//jQuery(window.parent.document).find("#login").fadeOut(1500);
		//window.parent.document.getElementById("LoginPage").src="register.html";
		//login",parent.document).attr("src","register.html")
		//jQuery(window.parent.document).find("#login").fadeIn(1500);
		var winDialog=window.open(ServletAddress+"register.html","tabs","toolbar=no,bottom=0,left=0,directories=no,status=no,menubar=no,scrollbars=no,location=no,resizable=yes,width=270,height=195");
		winDialog.focus();	
		});	
		

	});